<%@ page language="java" import="java.util.*" pageEncoding="gb2312" %>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map" %>
<%@ page import="net.sf.json.JSONObject" %>
<%@ page import="net.sf.json.JSONSerializer" %>
<%
   request.setCharacterEncoding("gb2312"); 
   response.reset();
   response.setContentType("application/vnd.ms-excel;charset=gb2312");
   response.setHeader("Content-disposition","attachment; filename=taskhistory.xls" );
   response.setCharacterEncoding("gb2312");
   response.getWriter().println(new String(new byte[] { (byte) 0xEF, (byte) 0xBB,(byte) 0xBF }));


   //String aa =System.Text.Encoding.UTF7;
%>
<html>
    <head>
    <%
    String tableData =request.getParameter("tableData");
    String columns = request.getParameter("tableColumns");

    Object list1 = JSONSerializer.toJSON(tableData);
    List columns1 = (List)JSONSerializer.toJSON(columns);
	
    Map dataMap1 = (Map) list1;
    List data = (List)dataMap1.get("rows");
    List columnList = (List)columns1.get(0);
    String[] columnsArr = new String[columnList.size()];
    
    
    for(int i = 0;i < columnList.size(); i++){
     Map map = (Map)columnList.get(i);
      columnsArr[i] = String.valueOf(map.get("field"));
    }
   
    %>
        <title>EXCEL</title>
        <!--<style type="text/css">
            table.common1 {
               width: 100%;
                  font-size: 9pt;
                  style-align: center;
                  background-color: #ffffff;
                  border: 1px solid #cccccc;
            }
            td.formtitle { font-size: 9pt;
              background:#a480b2;
             color:#ffffff;
              height:30px;
              text-align: center;
              border: 1px solid #cccccc;
            }
           
             td.formtitle2 {
              font-size: 9pt;
               background:#ffffff;
               color:#000000;
              height:30px;
              text-align: left;
              border: 1px solid #cccccc;
            }
        </style>
    --></head>
    <body>
     <form name="fm" method="post" >
       <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
       <table cellpadding="5" cellspacing="1"  align="center"  style="width: 100%;font-size: 9pt;style-align: center;background-color: #ffffff;border: 1px solid #cccccc;">
   <tr>
   <%for(int i = 1;i < columnList.size(); i++){
    Map map =(Map)columnList.get(i);
   %>
    <td class=formtitle align="center" nowrap style="width:13%;font-size: 9pt;background:#a480b2;color:#ffffff;height:30px;text-align: center;border: 1px solid #cccccc;"><%=map.get("title") %></td>
   <%} %>
   </tr>
   
   <%for(int j = 0;j < data.size(); j++){
    Map map =(Map)data.get(j);
   %> 
   <tr>
   <%
    for(int k = 1;k < columnsArr.length; k++){
     String field = columnsArr[k];
   %>
    <td class=formtitle2 align="left" nowrap style="width:13%;font-size: 9pt;background:#ffffff;color:#000000;height:30px;text-align: left;border: 1px solid #cccccc;"><%=map.get(field)==null?"":""+map.get(field) %></td>
    <%}%>
   </tr>
   <%} %>
        </table>
      </form>
     </body>
</html>